
#include "setting_up_new.h"
#include "sys_font.h"
#include "pt_fs.h"

static ui_setting_up_new_t  ui_set_up_new;


static  char * icon_esc[1] = 
{
    "Return.png",
};


static int setting_up_new_esc_clicked(lv_event_t* event)
{

    page_pop();
    
    return 0;
}

static void setting_up_new_esc_event_callback(lv_event_t* event)
{
    if (event->code == LV_EVENT_CLICKED) {

        debug_d("esc\n");
        setting_up_new_esc_clicked(event);
    }
}

int ui_setting_up_new_create(lv_obj_t *superview)
{
    char txt_buff[128];
    

    ui_set_up_new.img_bg = lv_obj_create(superview);

    lv_obj_set_pos(ui_set_up_new.img_bg,16,8);
    lv_obj_set_size(ui_set_up_new.img_bg,32,32);

	lv_obj_set_style_radius(ui_set_up_new.img_bg, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(ui_set_up_new.img_bg, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(ui_set_up_new.img_bg, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(ui_set_up_new.img_bg, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(ui_set_up_new.img_bg, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(ui_set_up_new.img_bg, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(ui_set_up_new.img_bg, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(ui_set_up_new.img_bg, 0,0);
    
    #if 1
    lv_obj_set_style_bg_opa(ui_set_up_new.img_bg,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(ui_set_up_new.img_bg,LV_OPA_100,0);
    lv_obj_set_style_bg_color(ui_set_up_new.img_bg,lv_color_make(0xff,0,0),0);
    #endif 
    //************************
    ui_set_up_new.img_esc = lv_img_create(ui_set_up_new.img_bg);
    lv_img_set_src(ui_set_up_new.img_esc,pt_fs_get(icon_esc[0]));
    lv_obj_set_pos(ui_set_up_new.img_esc,0,0);

    lv_obj_add_event_cb(ui_set_up_new.img_bg,setting_up_new_esc_event_callback,LV_EVENT_ALL,NULL);
    //***********************************************************
    ui_set_up_new.title = lv_label_create(superview);
    lv_obj_set_pos(ui_set_up_new.title,102,6);
    lv_obj_set_size(ui_set_up_new.title,276,25);
    lv_obj_set_style_text_align(ui_set_up_new.title,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(ui_set_up_new.title,LV_OPA_100,LV_PART_MAIN);
    lv_obj_set_style_text_color(ui_set_up_new.title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(ui_set_up_new.title, lv_font_get(18), LV_STATE_DEFAULT);
    lv_label_set_text( ui_set_up_new.title, "固件更新");
    //***********************************************************
    ui_set_up_new.txt1 = lv_label_create(superview);
    lv_obj_set_pos(ui_set_up_new.txt1,24,120);
    lv_obj_set_size(ui_set_up_new.txt1,432,40);
    lv_obj_set_style_text_align(ui_set_up_new.txt1,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(ui_set_up_new.txt1,LV_OPA_100,LV_PART_MAIN);
    lv_obj_set_style_text_color(ui_set_up_new.txt1,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(ui_set_up_new.txt1, lv_font_get(18), LV_STATE_DEFAULT);
    lv_label_set_text( ui_set_up_new.txt1, "当前已经是最新版本");
    //**********************************************************************************************

    ui_set_up_new.txt2 = lv_label_create(superview);
    lv_obj_set_pos(ui_set_up_new.txt2,24,160);
    lv_obj_set_size(ui_set_up_new.txt2,432,40);
    lv_obj_set_style_text_align(ui_set_up_new.txt2,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(ui_set_up_new.txt2,LV_OPA_100,LV_PART_MAIN);
    lv_obj_set_style_text_color(ui_set_up_new.txt2,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(ui_set_up_new.txt2, lv_font_get(18), LV_STATE_DEFAULT);

    memset(txt_buff,0,sizeof(txt_buff));
    snprintf(txt_buff,128,"当前版本%s","v0.1");

    lv_label_set_text( ui_set_up_new.txt2, txt_buff);
    //**********************************************************************************************


    return 0;
}

int ui_setting_up_new_destroy(lv_obj_t *superview)
{
    if(ui_set_up_new.img_bg){
        lv_obj_del(ui_set_up_new.img_bg);
        ui_set_up_new.img_bg = NULL;
        ui_set_up_new.img_esc = NULL;
    }
    if(ui_set_up_new.title){
        lv_obj_del(ui_set_up_new.title);
        ui_set_up_new.title = NULL;
    }   
    if(ui_set_up_new.txt1){
        lv_obj_del(ui_set_up_new.txt1);
        ui_set_up_new.txt1 = NULL;
    } 
    if(ui_set_up_new.txt2){
        lv_obj_del(ui_set_up_new.txt2);
        ui_set_up_new.txt2 = NULL;
    } 

    return 0;
}

static void setting_up_new_on_view_did_load(page_base_t* self)
{
    ui_setting_up_new_create(self->root);
}

static void setting_up_new_on_view_did_unload(page_base_t* self)
{
    ui_setting_up_new_destroy(self->root);
}

static page_vtable_t setting_up_new_param = {
    .on_custom_attr_config  = NULL,
    .on_view_load           = NULL,
    .on_view_did_load       = setting_up_new_on_view_did_load,
    .on_view_will_appear    = NULL,
    .on_view_did_appear     = NULL,
    .on_view_will_disappear = NULL,
    .on_view_did_disappear  = NULL,
    .on_view_did_unload     = setting_up_new_on_view_did_unload,
};


page_vtable_t* lv_page_setting_up_new_create(void)
{
    return &setting_up_new_param;
}
